class Activity {
  final int? id;
  final String date;
  final String activityType;
  final int? duration; // 以分钟为单位
  final String? notes;
  final String createdAt;

  Activity({
    this.id,
    required this.date,
    required this.activityType,
    this.duration,
    this.notes,
    required this.createdAt,
  });

  // 从数据库映射创建Activity对象
  factory Activity.fromMap(Map<String, dynamic> map) {
    return Activity(
      id: map['id'] as int?,
      date: map['date'] as String,
      activityType: map['activity_type'] as String,
      duration: map['duration'] as int?,
      notes: map['notes'] as String?,
      createdAt: map['created_at'] as String,
    );
  }

  // 将Activity对象转换为数据库映射
  Map<String, dynamic> toMap() {
    return {
      'id': id,
      'date': date,
      'activity_type': activityType,
      'duration': duration,
      'notes': notes,
      'created_at': createdAt,
    };
  }

  // 复制并修改Activity对象
  Activity copyWith({
    int? id,
    String? date,
    String? activityType,
    int? duration,
    String? notes,
    String? createdAt,
  }) {
    return Activity(
      id: id ?? this.id,
      date: date ?? this.date,
      activityType: activityType ?? this.activityType,
      duration: duration ?? this.duration,
      notes: notes ?? this.notes,
      createdAt: createdAt ?? this.createdAt,
    );
  }
} 